package com.four.shop.controller;

import com.four.shop.entity.Property;
import com.four.shop.service.PropertyService;
import com.guli.common.utils.PageUtils;
import com.guli.common.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;

/**
 * @Author:wsy
 * @Date: 2021/12/9/15:35
 */
@RestController
@RequestMapping("shop/property")
public class PropertyController {

    /**
     * 规格列表
     *
     * @param
     *
     * @return
     */
    @Autowired
    private PropertyService propertyService;

    /**
     * 规格列表
     *
     * @param map
     *
     * @return
     */
    @GetMapping("/propertyList")
    public R propertyList(@RequestParam Map <String,Object> map) {
        PageUtils page = propertyService.propertyList(map);
        return R.ok().put("page",page);
    }

    /**
     * 前台传过来的是字符串
     * 批量删除
     * @param ids
     * @return
     */
    @DeleteMapping("delBatch/{ids}")
    public R delBatch(@PathVariable("ids")String ids){
        propertyService.delBatch(ids);
        return R.ok();
    }

    /**
     * 前台传过来的是数组
     * 批量删除
     * @param ids
     * @return
     */
    @DeleteMapping("delBatch2")
    public R delBatch2(@RequestBody Integer[] ids){
        propertyService.delBatch2(Arrays.asList(ids));
        return R.ok();
    }
    /**
     * 添加2
     *
     * @param property
     *
     * @return
     */
    @PostMapping("/propertyadd3")
    public R propertyadd3( Property property){
        propertyService.propertyadd3(property);
        return R.ok();
    }
}
